from django.db import models
from datetime import datetime


# 基类
class Base(models.Model):
    # 创建时间
    create_time = models.DateTimeField(default=datetime.now(), null=True)

    class Meta:
        abstract = True


# 用户收藏表
class UserFlow(Base):

    # 用户信息
    uid = models.IntegerField()
    # 商品信息
    gid = models.IntegerField()

    class Meta:
        db_table = 'userflow'


# 用户评论表
class Comment(Base):

    # 评论内容
    content = models.CharField(max_length=200)
    # 评论用户
    uid = models.IntegerField()
    # 评论的哪个商品
    gid = models.IntegerField()

    class Meta:
        db_table = 'comment'
        

# 用户类
class User(Base):
    # 用户名
    username = models.CharField(max_length=200)
    # 密码
    password = models.CharField(max_length=200)
    # 头像
    img = models.CharField(max_length=200, null=True)
    # 视频
    vedio = models.CharField(max_length=255, null=True)
    # 用户类别  0普通用户  1超级管理员
    type = models.IntegerField(default=0, null=True)

    # 声明表名
    class Meta:
        db_table = 'user'


# 幻灯片
class Pics(Base):
    # 名称
    title = models.CharField(max_length=200)
    # 链接
    link = models.CharField(max_length=200)
    # 图片
    img = models.CharField(max_length=200)

    class Meta:
        db_table = 'pics'


# 分类表
class Cate(models.Model):
    # 分类名称
    name = models.CharField(max_length=50)
    pid = models.IntegerField()

    class Meta:
        db_table = 'cate'


# 商品表
class Goods(Base):
    # 商品名称
    name = models.CharField(max_length=100)
    # 商品价格
    price = models.IntegerField()
    # 商品规格
    parms = models.CharField(max_length=200)
    # 商品头图
    img = models.CharField(max_length=200, null=True)
    # 视频展示
    video = models.CharField(max_length=200, null=True)
    # 商品简介
    desc = models.CharField(max_length=300)
    # 关注数
    flow = models.IntegerField(default=0, null=True)
    # 分类id
    cate_id = models.IntegerField()

    class Meta:
        db_table = 'goods'
